package com.geezdata.cps.cqrs.command.bus.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.geezdata.cps.base.request.BaseRequest;
import com.geezdata.cps.base.response.BaseResponse;
import com.geezdata.cps.cqrs.command.Command;
import com.geezdata.cps.cqrs.command.bus.CommandBus;

public class DefaultCommandBus implements CommandBus {
    private Logger logger = LoggerFactory.getLogger(getClass());

	@Override
    public <REQ extends BaseRequest, RES> BaseResponse<RES> dispatch(Command<REQ, RES> cmd, REQ request) {
        logger.debug("{} be dispatched.", cmd.getClass().getName());
        return cmd.execute(request);
    }
}
